/*
 * Powered By 
 * Since 2010 - 2016
 */

package com.rf.sys.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rf.sys.dao.SqlAdapterMapper;
import com.rf.sys.service.CommonService;
import com.rf.sys.utils.UuidUtil;

@Service("commonService")
public class CommonServiceImpl implements CommonService{
	
	@Autowired
   	private SqlAdapterMapper sqlAdapterMapper;//注入dao
	
	/**
	 * 获取流水号
	 * @param type 类型	1：放行卡	2：申报	3：备案
	 */
	public String getSerialNo(int type) throws Exception{
		String result = "OT";
		switch (type) {
			case 1:
				result = "FX";
				break;
			case 2:
				result = "SD";
				break;
			case 3:
				result = "BF";
				break;
			case 4:
				result = "HG";
				break;
		}
		//获取当年日期
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
		result = result + df.format(new Date());
//		//查询序列号
//		String sql = "Select SEQ_SERIAL.NextVal From Dual";
//		List<Map<String, Object>> list = sqlAdapterMapper.selectSQL(sql);
//		int num = 0;
//		if(list.size()>0){
//			BigDecimal n = (BigDecimal) list.get(0).get("NEXTVAL");
//			num = n.intValue();
//		}
//		//根据位数补位
//		if(num>9 && num<=99){
//			result = result+"00"+num;
//		}else if(num>99 && num<=999){
//			result = result+"0"+num;
//		}else if(num>999){
//			result = result+num;
//		}else{
//			result = result+"000"+num;
//		}
		return result;
	}
	
}
